package com.twu.biblioteca.Domain;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

/**
 * Created by hjli on 9/10/14.
 */
public class MenuService {

    BufferedReader buf;

    public List<String> getCustomerMainMenuItems() {
        return customerMainMenuItems;
    }

    public List<String> getBookSubMenuItems() {
        return bookSubMenuItems;
    }

    public List<String> getMovieSubMenuItems() {
        return movieSubMenuItems;
    }

    private List<String> customerMainMenuItems;

    public List<String> getLibrarianMainMenuItems() {
        return librarianMainMenuItems;
    }

    public List<String> getUnLoginMainMenuItems() {
        return unLoginMainMenuItems;
    }

    private List<String> unLoginMainMenuItems;
    private List<String> librarianMainMenuItems;
    private List<String> bookSubMenuItems;
    private List<String> movieSubMenuItems;

    public void setMenuItems(List<String> menuItems) {
        this.menuItems = menuItems;
    }

    public List<String> menuItems;

    public MenuService(){

        buf = new BufferedReader(new InputStreamReader(System.in));

        unLoginMainMenuItems = Arrays.asList("List Books", "List Movies", "Login In");

        librarianMainMenuItems = Arrays.asList("List Books", "List Movies", "Personal Info", "List Record", "Login Out", "Quit");

        customerMainMenuItems = Arrays.asList("List Books", "List Movies", "Personal Info", "Login Out", "Quit");

        bookSubMenuItems = Arrays.asList("Checkout Book", "Return Book", "Quit");

        movieSubMenuItems = Arrays.asList("Checkout Movie", "Return Movie", "Quit");
    }

    public String showMainMenu(){
        String temp = "--------------------------Menu-------------------------\n";
        for(String menuItem : menuItems){
            temp += menuItem + " |";
        }
        temp += "\n----------------------End of Menu----------------------";
        return temp;
    }

    public String clickMenu(String input) throws Exception {
        String result = null;
        if(input.equals("Quit")){
            throw new Exception("Quit");
        }
        else{
            for(String menuItem : menuItems){
                if(input.equals(menuItem)){
                    result = menuItem;
                    break;
                }
            }
        }
        if(result == null){
            return "Select a valid option!";
        }
        else{
            return result;
        }

    }


























}
